<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>keepalive - WebIM</title>
</head>
<body>
receiver: <input type="text" id="receiver" value="2000000001"/>
message: <input type="text" id="message" value="hello"/>
<a id="sendbtn" href="#nogo">send</a>

<script type="text/javascript" src="http://imstatic.bang.360.cn/js/jquery_plugin/jquery.js"></script>
<script type="text/javascript" src="http://imstatic.bang.360.cn/chat-channel.js"></script>

<script type="text/javascript">
/*
 * Author: yuwei.mu@gmail.com
 * Date: 2013-05
*/ 

function Bootstrap() {
  var ajax_channel = new AjaxChannel('/subscribe', '/publish');
  // var qihu_channel = new QihuChannel(ajax_channel);
  // var mutex_channel = new MutexAjaxChannel(ajax_channel);
  // var qihu_channel = new QihuChannel(mutex_channel);

  var controller = new ChatController(ajax_channel);
  // var controller = new ChatController(mutex_channel);
  // var controller = new ChatController(qihu_channel);

  controller.AttachView('debug', new DebugView()); 
  controller.StartReceiveMessage();

  window.g_controller = controller;
}

var g_test_count = 0;
function TestSend() {
  var uid = Cookie('qimrid');
  if (uid == null) {
    uid = Cookie('qimtid');
  }
  g_controller.SendMessage(uid, "keepalive-" + (++g_test_count));
  // if (g_test_count < 50)
  setTimeout(TestSend, 300 + 500 * Math.random()); 
}

$(document).ready(function() {
  // AjaxChannelUnitTest(500);
  // StorageQueueUnitTest(500);
  // QihuChannelUnitTest(500);
  Bootstrap();

  $('#sendbtn').click(function() {
    g_controller.SendMessage($("#receiver").val(), $("#message").val());
  });

  setTimeout(TestSend, 300); 
});

</script>
</body>
</html>
